package com.qf.ssm.common.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
   @author 86155
   @ClassName: com.qf.common.vo.ResponseResult
   @Description: 该类的功能描述
   @date: 2021/10/8 17:36 
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ResponseResult<T> {
    private int status;
    private String msg;
    private T data;
    public static <T> ResponseResult<T> success(T data) {

        return success(data, ResponseCode.SUCCESS);
    }

    public static <T> ResponseResult<T> success(T data, ResponseCode responseCode) {
        return new ResponseResultBuilder<T>()
                .msg(responseCode.getMsg())
                .status(responseCode.getStatus())
                .data(data)
                .build();
    }


    public static <T> ResponseResult<T> error() {
        return error(ResponseCode.ERROR);
    }

    public static <T> ResponseResult<T> error(ResponseCode responseCode) {
        return error(responseCode.getStatus(), responseCode.getMsg());
    }

    public static <T> ResponseResult<T> error(int status, String msg) {
        return new ResponseResultBuilder<T>()
                .msg(msg)
                .status(status)
                .build();
    }

}